package com.bilicraft.plugin.kexue.commands;

import java.io.File;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

import com.bilicraft.plugin.kexue.ShellUser;

public class BiliCmdMkdir extends BiliCmd{
	public BiliCmdMkdir(){
		nofArgs = 1;
	}

	public boolean doExec(CommandSender sender, Command cmd, String label, String[] args, ShellUser shellUser){
		try{
			File fdir = new File(shellUser.curdir);
			shellUser.curdir = fdir.getCanonicalPath();
			File cfile = new File(fdir, args[0]);
			if(cfile.exists() && cfile.isDirectory()){
				sender.sendMessage("Dir exists!");
				return true;
			}
			if(cfile.mkdir()){
				sender.sendMessage("Dir created.");
				return true;
			}
			return true;
		}catch(Exception e){
			e.printStackTrace();
		}
		return false;
	}
}
